#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
struct pp{
    ll j, y, t,sum;
}a[2];
void solve()
{
    ll n;
    cin >> n;
    for(ll i=1;i<=n;i++)
    {
        ll c,p;
        cin >> c >> p;
        if(p==1)
            a[c].j++;
        else if(p==2)
            a[c].y++;
        else if(p==3)
            a[c].t++;
        a[c].sum++;
    }
    cout << a[0].j << " " << a[0].y << " " << a[0].t << endl;
    cout << a[1].j << " " << a[1].y << " " << a[1].t << endl;
    
        if(a[0].sum==a[1].sum)
        {
            if(a[0].j>a[1].j)
            {
                cout << "The first win!";
                return;
            }
            else if(a[0].j==a[1].j)
            {
                if(a[0].y>a[1].y)
                {
                    cout << "The first win!";
                    return;
                }
                else if(a[0].y==a[1].y)
                {
                    if(a[0].t>a[1].t)
                    {
                        cout << "The first win!";
                    return;
                    }
                }
            }
        }
        cout << "The second win!";
    
}
int main()
{
    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
   return 0;
}
